<template>
	<view class="content-tabar">
		<view class="header flex-column">
			<view>
				<uni-search-bar 
				class="header-seach"
				placeholder="搜索商品"
				@input="input" 
				:focus="false" 
				v-model="searchValue" 
				radius="30"
				clearButton="none"
				cancelButton="none"
								>
							</uni-search-bar>
			</view>
			<view class="banner">
				<image src="../../static/index/banner.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="content-tab">
			<view class="flex-row">
				<view class="flex-column tab">
					<view v-for="(tab,index) in categorize">
						<view :class="index==selected?`select-tab flex-column`:`tab flex-column`" @tap="selectCateg(index)">
							<image class="tab-img" :src="tab.icon" mode="scaleToFill"></image>
							<view class="tab-txt">{{tab.name}}</view>
						</view>
					</view>
				</view>
				<view class="flex-column sp">
					<view class="sp-header">{{categorize[selected].name}}</view>
					<scroll-view :scroll-y="true" :class="has_cat?`sp-scroll-has`:`sp-scroll`">
						<view class="flex-row sp-scroll-goods flex-content-between" v-for="item in categorize[selected].data" @tap="gotopage">
							<view class="flex-row">
								<image class="sp-scroll-goods-img" :src="item.icon" mode="widthFix"></image>
								<view class="flex-column sp-scroll-goods-txt">
									<view class="sp-scroll-goods-txt1">{{item.name}}</view>
									<view class="sp-scroll-goods-txt2"><text>{{item.discount}}</text></view>
									<view class="flex-row sp-scroll-goods-price">
										<view class="sp-scroll-goods-txt3">￥{{item.price}}</view>
										<view class="sp-scroll-goods-txt4">￥{{item.orig_price}}</view>
									</view>
								</view>
							</view>
							<view class="flex-column-reverse sp-scroll-goods-not-cart">
								<view class="flex-content-end">
									<!-- <image class="sp-scroll-goods-not-cart-img" src="../../static/index/addcart.png" mode="widthFix"></image> -->
									<view class="sp-scroll-goods-not-cart-txt" @tap.stop="addCart">+</view>
								</view>
								
							</view>
						</view>
					</scroll-view>
				</view>
			</view>
		</view>
		<view v-if="has_cat">
			<!-- #ifdef H5 -->
			<mu-suspension bottom="105" >
				<mu-shopping-cart :show_goods="show_goods" :all_cart="all_cart" :goods_cart="goods_cart" :settlement="settlement"></mu-shopping-cart>
			</mu-suspension>
			<!-- #endif -->
			
			<!-- #ifndef H5 -->
			<mu-suspension bottom="0">
				
			</mu-suspension>
			<!-- #endif -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				searchValue: '',//搜索数据
				selected:0,//当前选择的类型下标
				has_cat:false,//显示购物车
				show_goods:false,//显示购物车商品
				all_cart:true,//全选
				goods_cart:[//购物车商品
					{
						id:"",
						selected:true,
					},
					{
						id:"",
						selected:false,
					},
					{
						id:"",
						selected:true,
					},
					{
						id:"",
						selected:false,
					},
					{
						id:"",
						selected:true,
					},
					{
						id:"",
						selected:false,
					},
					{
						id:"",
						selected:true,
					},
					{
						id:"",
						selected:true,
					},
					{
						id:"",
						selected:false,
					},
					{
						id:"",
						selected:true,
					},
					{
						id:"",
						selected:true,
					},
					{
						id:"",
						selected:true,
					}
				],
				//列表
				categorize:[
					{
						id:"1",
						name:"新品上市",
						icon:"../../static/index/xinpin.png",
						page:1,
						data:[
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
						]
					},
					{
						id:"2",
						name:"精选套餐",
						icon:"../../static/index/jinxuan.png",
						page:1,
						data:[
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"竹笋牛腩",
								icon:"../../static/index/zsnl.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
						]
					},
					{
						id:"3",
						name:"折扣专区",
						icon:"../../static/index/zhekou.png",
						page:1,
						data:[
							{
								id:1,
								name:"辣子鸡",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"竹笋牛腩",
								icon:"../../static/index/zsnl.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
						]
					},
					{
						id:"4",
						name:"饮品",
						icon:"../../static/index/yinpin.png",
						page:1,
						data:[
							{
								id:1,
								name:"辣子鸡22222221584613543541354",
								icon:"../../static/index/lzj.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"竹笋牛腩",
								icon:"../../static/index/zsnl.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
							{
								id:1,
								name:"辣子鸡1",
								icon:"../../static/index/gbjd.png",
								price:"49.28",
								orig_price:"56",
								discount:"8.8"
							},
						]
					},
				]
			}
		},
		onLoad() {

		},
		methods: {
			//去结算
			settlement(){
				uni.navigateTo({
					url:'/pages/order/craete_order'
				})
			},
			//添加购物车
			addCart(){
				this.has_cat = true
			},
			//输入搜索
			input(e){
				console.log(e);
			},
			//选中不同的类型
			selectCateg(index){
				this.selected = index
			},
			//显示购物车商品
			showGoods(){
				this.show_goods = !this.show_goods;
				// console.log(this.show_goods);
			},
			gotopage(){
				uni.navigateTo({
					url:'/pages/order/goods_info'
				})
			}
		}
	}
</script>

<style lang="scss">
	.cart-goods-addel-one{
		margin-top: 68rpx;
	}
	.cart-goods-addel{
		margin-right: 30rpx;
	}
	.cart-goods-addel-img1{
		width: 40rpx;
		height: 40rpx;
		margin-right: 24rpx;
	}
	.cart-goods-addel-img2{
		width: 40rpx;
		height: 40rpx;
		margin-left: 24rpx;
	}
	.cart-goods-scroll{
		width: 100%;
		height: 570rpx;
	}
	.cart-goods-scroll-centos{
		margin-top: 38rpx;
	}
	.cart-goods-scroll-ones{
		width: 100%;
		height: 108rpx;
		padding-left: 30rpx;
		margin-bottom: 60rpx;
	}
	.cart-goods-scroll-img1{
		width: 42rpx;
		height: 42rpx;
	}
	.cart-goods-scroll-img2{
		width: 108rpx;
		margin-left: 30rpx;
	}
	.cart-goods-scroll-text{
		margin-left: 20rpx;
	}
	.cart-goods-scroll-text1{
		font-size: 30rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
	}
	.cart-goods-scroll-text2{
		font-size: 32rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: $default-button-color;
		margin-top: 24rpx;
	}
	.cart-goods{
		width: 100%;
		height: 658rpx;
	}
	.cart-goods-img1{
		width: 42rpx;
		height: 42rpx;
	}
	.cart-goods-img2{
		width: 29rpx;
		height: 29rpx;
		// margin-right: 10rpx;
	}
	.cart-goods-txt1{
		font-size: 28rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		margin-left: 22rpx;
	}
	.cart-goods-header{
		width: 750rpx;
		height: 88rpx;
		background: #F4F4F4;
		border-radius: 32rpx 32rpx 0px 0px;
		opacity: 1;
		padding-bottom: 22rpx;
	}
	.sp-scroll-goods-not-cart-txt{
		width: 40rpx;
		height: 40rpx;
		border-radius: 20rpx;
		background-color: $default-button-color;
		color: #FFFFFF;
		text-align: center;
		line-height: 40rpx;
		margin-bottom: 8rpx;
		margin-right: 30rpx;
	}
	.cart{
		margin-left: 30rpx;
		width: 690rpx;
		height: 100rpx;
		background: #FFFFFF;
		box-shadow: 0px 0px 12rpx 2rpx rgba(0,0,0,0.1);
		border-radius: 50rpx 50rpx 50rpx 50rpx;
		opacity: 1;
	}
	.cart_bg{
		width: 100%;
		background-color: #FFFFFF;
		border-radius: 32rpx 32rpx 0px 0px;
	}
	
	.cart-img{
		width: 68rpx;
		height: 50rpx;
		margin-left: 40rpx;
		margin-top: 24rpx;
	}
	.cart-price{
		font-size: 32rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: $default-button-color;
		margin-top: 28rpx;
		margin-left: 30rpx;
	}
	.cart-badg{
		margin-left: -30rpx;
	}
	.cart-js{
		width: 188rpx;
		height: 100rpx;
		background: $default-button-color;
		border-radius: 0px 50rpx 50rpx 0px;
		opacity: 1;
		color: #FFFFFF;
		text-align: center;
		line-height: 100rpx;
	}
	.sp-scroll-goods-not-cart-img{
		width: 40rpx;
	}
	.sp-scroll-goods-not-cart{
		
	}
	.sp-scroll-goods-txt{
		margin-left: 16rpx;
		margin-top: 8rpx;
	}
	.sp-scroll-goods-price{
		margin-top: 50rpx;
	}
	.sp-scroll-goods-txt1{
		font-size: 32rpx;
		width: 300rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
		 overflow: hidden;
		    text-overflow: ellipsis;
		    white-space: nowrap;
	}
	.sp-scroll-goods-txt2{
		font-size: 20rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: $default-button-color;
		margin-top: 10rpx;
		// background-color: #FFECE5;
	}
	.sp-scroll-goods-txt2>text{
		background-color: #FFECE5;
		padding: 2rpx 8rpx;
	}
	.sp-scroll-goods-txt3{
		font-size: 30rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: $default-button-color;
	}
	.sp-scroll-goods-txt4{
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #CCCCCC;
		margin-left: 8rpx;
		line-height: 40rpx;
		text-decoration: line-through
	}
	.sp{
		width: 598rpx;
		background-color: #FFFFFF;
	}
	.sp-header{
		font-size: 28rpx;
		font-family: PingFang SC-Bold, PingFang SC;
		font-weight: bold;
		color: #333333;
		margin-left: 20rpx;
	}
	/* #ifdef H5 */
	.sp-scroll{
		width: 100%;
		height: calc(100vh - 585rpx);
	}
	/* #endif */
	/* #ifndef H5 */
	.sp-scroll{
		width: 100%;
		height: calc(100vh - 485rpx);
	}
	/* #endif */
	/* #ifdef H5 */
	.sp-scroll-has{
		width: 100%;
		height: calc(100vh - 685rpx);
		padding-bottom: 100rpx;
	}
	/* #endif */
	/* #ifndef H5 */
	.sp-scroll-has{
		width: 100%;
		height: calc(100vh - 585rpx);
		padding-bottom: 100rpx;
	}
	/* #endif */
	.sp-scroll-goods{
		margin-left: 20rpx;
		margin-right: 30rpx;
		padding-top: 11rpx;
		padding-bottom: 11rpx;
		margin-top: 28rpx;
		margin-bottom: 44rpx;
	}
	.sp-scroll-goods-img{
		width: 182rpx;
	}
	.select-tab{
		width: 152rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
		border-left: 4rpx solid $default-button-color;
		// background-color: #FFFFFF;
	}
	.tab{
		width: 152rpx;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}
	.tab-img{
		width: 54rpx;
		height: 46rpx;
		margin-left: 50rpx;
	}
	.tab-txt{
		font-size: 24rpx;
		font-family: PingFang SC-Regular, PingFang SC;
		font-weight: 400;
		color: #333333;
		text-align: center;
	}
	.content-tab{
		width: 100%;
	}
	.banner{
		width: 690rpx;
		// background-color: rebeccapurple;
		// height: 214rpx;
		margin-left: 30rpx;
	}
	.banner>image{
		width: 690rpx;
	}
	.header {
		width: 100%;
		// height: 434rpx;
		background-color: #FFFFFF;
		padding-bottom: 48rpx;
	}

	.header-seach {
		width: 432rpx;
		margin-top: 24rpx;
	}
</style>